<?php

/**
 * Employee form base class.
 *
 * @method Employee getObject() Returns the current form's model object
 *
 * @package    virtualstore
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseEmployeeForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'firstname'         => new sfWidgetFormInputText(),
      'middlename'        => new sfWidgetFormInputText(),
      'lastname'          => new sfWidgetFormInputText(),
      'lastname2'         => new sfWidgetFormInputText(),
      'nationalId'        => new sfWidgetFormInputText(),
      'socialSecurityId'  => new sfWidgetFormInputText(),
      'active'            => new sfWidgetFormInputCheckbox(),
      'dateOfBirth'       => new sfWidgetFormDate(),
      'gender'            => new sfWidgetFormInputText(),
      'marital_status_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('MaritalStatus'), 'add_empty' => false)),
      'slug'              => new sfWidgetFormInputText(),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
      'created_by'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('created_by_fk'), 'add_empty' => false)),
      'updated_by'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('updated_by_fk'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'firstname'         => new sfValidatorString(array('max_length' => 100)),
      'middlename'        => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'lastname'          => new sfValidatorString(array('max_length' => 100)),
      'lastname2'         => new sfValidatorString(array('max_length' => 100)),
      'nationalId'        => new sfValidatorString(array('max_length' => 20)),
      'socialSecurityId'  => new sfValidatorString(array('max_length' => 20)),
      'active'            => new sfValidatorBoolean(array('required' => false)),
      'dateOfBirth'       => new sfValidatorDate(),
      'gender'            => new sfValidatorRegex(array('max_length' => 1, 'pattern' => '/(M|F)/')),
      'marital_status_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('MaritalStatus'))),
      'slug'              => new sfValidatorString(array('max_length' => 200, 'required' => false)),
      'created_at'        => new sfValidatorDateTime(),
      'updated_at'        => new sfValidatorDateTime(),
      'created_by'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('created_by_fk'))),
      'updated_by'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('updated_by_fk'))),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Employee', 'column' => array('nationalid'))),
        new sfValidatorDoctrineUnique(array('model' => 'Employee', 'column' => array('socialsecurityid'))),
        new sfValidatorDoctrineUnique(array('model' => 'Employee', 'column' => array('slug'))),
      ))
    );

    $this->widgetSchema->setNameFormat('employee[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Employee';
  }

}
